#include "PersonalAudioEngine.h"
#include "StaticData.h"
#include "FishingJoyData.h"

PersonalAudioEngine* PersonalAudioEngine::_pInstace=0;

PersonalAudioEngine::PersonalAudioEngine()
{
}

PersonalAudioEngine::~PersonalAudioEngine()
{
}

PersonalAudioEngine& PersonalAudioEngine::getInstance()
{
	if(!_pInstace){
		static PersonalAudioEngine audioEngine;
		audioEngine.init();
		_pInstace=&audioEngine;
	}
	return *_pInstace;
}

bool PersonalAudioEngine::init()
{
	preloadBackgroundMusic(StaticData::getInstance()->stringFromKey("bg_music"));
	preloadEffect(StaticData::getInstance()->stringFromKey("sound_button"));
	preloadEffect(StaticData::getInstance()->stringFromKey("sound_shot"));

	setBackgroundMusicVolume(FishingJoyData::getInstance()->getMusicVolume());
	setEffectsVolume(FishingJoyData::getInstance()->getSoundVolume());
	return true;
}

void PersonalAudioEngine::setBackgroundMusicVolume(float volume)
{
	SimpleAudioEngine::setBackgroundMusicVolume(volume);
	FishingJoyData::getInstance()->setMusicVolume(volume);
}

void PersonalAudioEngine::setEffectsVolume(float volume)
{
	SimpleAudioEngine::setEffectsVolume(volume);
	FishingJoyData::getInstance()->setSoundVolume(volume);
}
